home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7670 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.7 KB

  1. Path: isonews.bbn.hp.com!hpbblb!news
  2. From: Matthias Dittrich <matti>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Low level reading and writing
  5. Date: 26 Feb 1996 07:48:27 GMT
  6. Organization: Hewlett-Packard Co.
  7. Message-ID: <4grokb$2mv@hpbblb.bbn.hp.com>
  8. References: <ragnaroek1996Feb22.090723.20448@news2.compulink.com>
  9. NNTP-Posting-Host: trabant.bbn.hp.com
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 1.1N (X11; I; HP-UX A.09.07 9000/712)
  14. X-URL: news:ragnaroek1996Feb22.090723.20448@news2.compulink.com
  15.  
  16. hodges@idirect.com (Hodges@idirect.com) wrote:
  17. > ...
  18. >My problem is as follows.... 
  19. >
  20. >The read and write functions only return the number of bytes read or 
  21. >written. So why is it necessary to increment "length++" after using strcpy 
  22. >function to copy "Happy Birthday." to outbuffer. By doing this, length 
  23. >actually returns the byte size including the NULL character. ?????
  24. >
  25. This is correct. The '\0' character has been written to your file. If you
  26. are reading your file, you will get it. So you get a correctly terminated
  27. c-string.
  28.  
  29. >
  30. >Question # 2:
  31. >
  32. >In standard I/O, the fprintf function can be used to write formatted output 
  33. >to a file associated with a file pointer. Can sprintf be used with Low level 
  34. >I/O to write formatted output to a file associated with a specific file 
  35. >handle? If not how would one go about writing to a low level file which 
  36. >would achieve the same results as fprintf does with Standard I/O?
  37. > ...
  38. The usage is the same as in your code. The function sprintf fills a buffer
  39. with your string. Use outbuffer for this and call write in the same way.
  40. Your problem is in both cases to ensure not to cross the buffers boundaries.
  41.  
  42. Good luck,
  43. Matthias
  44.  
  45.